server {
    listen      80;
    server_name  {{ item.domain }};

    access_log      /var/log/nginx/{{ item.name }}_access.log;
    error_log       /var/log/nginx/{{ item.name }}_error.log;
    ignore_invalid_headers off; #pass through headers from Jenkins which are considered invalid by Nginx server.

    location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
        #expires定义用户浏览器缓存的时间为7天，如果静态页面不常更新，可以设置更长，这样可以节省带宽和缓解服务器的压力
        rewrite ^/(.*)$ http://static.yicuicui.com/{{ item.name }}/$1 permanent; #若改 permanent 为 redirect ； 则发生的是 302 跳转     
    }

    location @{{ item.name }}_service {
            sendfile off;
            proxy_pass         http://{{ item.servers }}_servers;
            proxy_redirect     default;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_max_temp_file_size 0;

            #this is the maximum upload size
            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
    }

    location / {
            try_files $uri @{{ item.name }}_service;
    }
}